package com.example.toolproject.demo.service.serviceimpl;

import com.example.toolproject.demo.domain.LabReport;
import com.example.toolproject.demo.domain.LoginPageMessage;
import com.example.toolproject.demo.mapper.LabReportMapper;
import com.example.toolproject.demo.service.LabReportService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName LabReportServiceImpl
 * @Description TODO
 * @Author lvyongwei
 * @Date 2020-06-30 11:07
 **/
@Service
public class LabReportServiceImpl implements LabReportService {

    @Autowired
    private LabReportMapper labReportMapper;

    /**
     * 插入实验报告
     * @param labReport  实验报告实体
     * @return
     */
    @Override
    public boolean insertReport(LabReport labReport) {
        return labReportMapper.insertReport(labReport);
    }

    /**
     * 根据用户id获取实验报告
     * @param userId
     * @return
     */
    @Override
    public List<LabReport> getAllLabReportByUserId(Integer userId) {
        return labReportMapper.getAllLabReportByUserId(userId);
    }

    /**
     * 獲取用戶成績分佈
     * @return
     */
    @Override
    public LoginPageMessage getScoreUser() {
        return labReportMapper.getScoreUser();
    }

    /**
     * 獲取所有實驗總數
     * @return
     */
    @Override
    public long getAllLabReportCount() {
        return labReportMapper.getAllLabReportCount();
    }

    /**
     * 删除实验报告信息
     * @param labReportId
     * @return
     */
    @Override
    public boolean deleteLabReport(long labReportId) {
        return labReportMapper.deleteLabReport(labReportId);
    }

    /**
     * 根据实验报告id获取实验报告信息
     * @param labReportId
     * @return
     */
    @Override
    public LabReport getLabReportById(long labReportId) {
        return labReportMapper.getLabReportById(labReportId);
    }

    /**
     * 搜索数据
     * @param userId
     * @param message
     * @return
     */
    @Override
    public List<LabReport> getLabReportByMessage(Integer userId, String message) {
        return labReportMapper.getLabReportByMessage(userId,message);
    }
}
